
import { createApp } from 'vue'
import pinia from "@/stores/index.js";

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import  zhCn from 'element-plus/es/locale/lang/zh-cn'
import './assets/global.css'


import App from './App.vue'
import router from './router'

const app = createApp(App)

app.use(pinia)
app.use(router)

app.use(ElementPlus,{
    locale: zhCn,
})

app.directive('permission', (el, binding) => {
    // 当指令第一次绑定到元素时调用
    const permission = binding.value; // 获取绑定到指令的值，即权限名称
    // console.log('111',permission)
    const btns = pinia.state.value.menu.btnList
    const hasPermission = btns.includes(permission);

    // 如果用户没有权限，则隐藏元素
    if (!hasPermission) {
        el.style.display = 'none';
    }
})

app.mount('#app')
